<template>
	<jk-dialog
		v-model="showDialog"
		title="详情-工序"
		width="600px"
		:show-content-loading="showLoading"
		append-to-body
		:show-cancel-btn="false"
		:show-close-btn="true"
		:show-confirm-btn="false"
		@on-close="onVisibleChange(false)"
		@on-cancel="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="ruleForm" :model="ruleForm" label-width="110px" :show-message="false">
			<el-row>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="编码">
						<span class="read-only-2">{{ ruleForm.code }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="名称">
						<span class="read-only-2">{{ ruleForm.name }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="区域" prop="sortNum">
						<span class="read-only-2">{{ ruleForm.workshopName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="是否报工">
						<el-checkbox v-model="ruleForm.ifReport" disabled size="medium">是</el-checkbox>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="是否排产">
						<el-checkbox v-model="ruleForm.ifScheduling" disabled size="medium">是</el-checkbox>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="看板是否展示">
						<el-checkbox v-model="ruleForm.ifShow" disabled size="medium">是</el-checkbox>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="是否统计能耗">
						<el-checkbox v-model="ruleForm.ifLookElectricity" disabled size="medium">是</el-checkbox>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="排序">
						<span class="read-only-2">{{ ruleForm.sortNum }}</span>
					</el-form-item>
				</el-col>
			</el-row>
			<jk-divider-card title="工资及补贴" placement="center" class="margin-top-20">
				<el-row>
					<el-col ref="box2" :span="24">
						<!--<el-alert :show-icon="true" type="info" class="margin-bottom-10" :closable="false">
							<div>注：工资仅针对细纱和并条</div>
							<div class="margin-bottom-4">1、细纱, "单锭产量(M)"大于"基准产量(M)"时，单台工资=固定工资; 小于时，单台工资=单锭产量(M) * 单价</div>
							<div>2、并条,
								(1)、产量(M)大于基准产量时，工资 = 基准产量 * 左侧单价 + （产量(M) - 基准产量）* 右侧单价;
								(2)、产量(M)小于基准产量时，工资 = 产量(M) * 左侧单价
							</div>
						</el-alert>-->
						<el-form-item class="margin-bottom-10" label="单价">
							<div class="flex-start-center">
								<jk-number-input v-model="ruleForm.unitPrice" disabled placeholder="单价" />
								<!--<jk-number-input v-model="ruleForm.referenceOutput" disabled placeholder="基准产量(M)" />-->
								<!--<jk-number-input v-model="ruleForm.regularSalary" disabled :placeholder="['BT', 'TB', 'EB', 'MB'].includes(ruleForm.code.toUpperCase()) ? '单价' : '固定工资'" />-->
							</div>
						</el-form-item>
					</el-col>
					<!--<el-col :span="24">
						<el-form-item class="margin-bottom-10" label="满勤补贴标准" prop="fullAttendanceSubsidy">
							<jk-number-input v-model="ruleForm.fullAttendanceSubsidy" disabled placeholder="满勤补贴金额" class="margin-bottom-10" />
							<jk-table border :data="ruleForm.fullAttendanceSubsidyConfigList || []" :max-height="dialogTableHeight - 160">
								<vxe-column title="缺勤天数" align="right" field="minDay" :min-width="180">
									<template slot-scope="scope">
										<div class="flex-start-center">
											<jk-number-input v-model="scope.row.minDay" disabled size="small" placeholder="最小天数" />
											<span>~</span>
											<jk-number-input v-model="scope.row.maxDay" disabled size="small" placeholder="最大天数" />
										</div>
									</template>
								</vxe-column>
								<vxe-column title="扣减金额" align="right" field="deductionAmount" :min-width="100">
									<template slot-scope="scope">
										<jk-number-input v-model="scope.row.deductionAmount" disabled size="small" placeholder="扣减金额" />
									</template>
								</vxe-column>
							</jk-table>
						</el-form-item>
					</el-col>-->
				</el-row>
			</jk-divider-card>
		</el-form>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    import { spinProcessGet } from '../../../api/technology/process';

    export default {
        name: 'Process',
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataId: {
                type: [String, Number],
                default: ''
            }
        },
        mixins: [calHeight],
        data() {
            return {
                showDialog: false,
                showLoading: true,
                ruleForm: {
                    code: ''
                }
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                }
            },
            getDetailRequest() {
                this.showLoading = true;
                return spinProcessGet({ id: this.dataId }).then(res => {
                    this.showLoading = false;
                    if (res.data.status === 200) {
                        const resData = res.data.res || {};
                        resData.fullAttendanceSubsidyConfigList = resData.fullAttendanceSubsidyConfigList || [];
                        this.ruleForm = resData;
                    }
                });
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal && this.dataId) {
                    this.getDetailRequest();
                }
            }
        }
    };
</script>
